<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
	<meta name="keywords" content="NacosSync,migration,user guide" />
	<meta name="description" content="NacosSync migration user manual" />
	<!-- 网页标签标题 -->
	<title>NacosSync migration user guide</title>
	<link rel="shortcut icon" href="https://img.alicdn.com/tfs/TB1hgJpHAPoK1RjSZKbXXX1IXXa-64-64.png"/>
	<link rel="stylesheet" href="/build/documentation.css" />
</head>
<body>
	<div id="root"><div class="documentation-page" data-reactroot=""><header class="header-container header-container-normal"><div class="header-body"><a href="/en-us/index.html"><img class="logo" src="/img/nacos_colorful.png"/></a><div class="search search-normal"><span class="icon-search"></span></div><span class="language-switch language-switch-normal">中</span><div class="header-menu"><img class="header-menu-toggle" src="/img/menu_gray.png"/><ul><li class="menu-item menu-item-normal"><a href="/en-us/index.html">HOME</a></li><li class="menu-item menu-item-normal menu-item-normal-active"><a href="/en-us/docs/quick-start.html">DOCS</a></li><li class="menu-item menu-item-normal"><a href="/en-us/blog">BLOG</a></li><li class="menu-item menu-item-normal"><a href="/en-us/community">COMMUNITY</a></li><li class="menu-item menu-item-normal"><a href="https://cn.aliyun.com/product/aliware/mse?spm=nacos-website.topbar.0.0.0">NACOS IN CLOUD</a><img class="menu-img" src="https://img.alicdn.com/tfs/TB1esl_m.T1gK0jSZFrXXcNCXXa-200-200.png"/></li><li class="menu-item menu-item-normal"><a href="http://console.nacos.io/nacos/index.html">DEMO-CONSOLE</a></li></ul></div></div></header><div class="bar"><div class="bar-body"><img src="/img/docs.png" class="front-img"/><div class="bar-title"><span>Documentation</span><div class="bone bone-light"></div></div><img src="/img/docs.png" class="back-img"/></div></div><section class="content-section"><div class="content-body"><div class="sidemenu"><div class="sidemenu-toggle"><img src="https://img.alicdn.com/tfs/TB1E6apXHGYBuNjy0FoXXciBFXa-200-200.png"/></div><ul><li class="menu-item menu-item-level-1"><span>Nacos </span><ul><li style="height:180px;overflow:hidden" class="menu-item menu-item-level-2"><span>What is Nacos<img style="transform:rotate(0deg)" class="menu-toggle" src="/img/arrow_down.png"/></span><ul><li class="menu-item menu-item-level-3"><a href="/en-us/docs/what-is-nacos.html" target="_self">What is Nacos</a></li><li class="menu-item menu-item-level-3"><a href="/en-us/docs/concepts.html" target="_self">Concepts</a></li><li class="menu-item menu-item-level-3"><a href="/en-us/docs/architecture.html" target="_self">Architecure</a></li><li class="menu-item menu-item-level-3"><a href="/en-us/docs/feature-list.html" target="_self">Feature list</a></li></ul></li><li style="height:324px;overflow:hidden" class="menu-item menu-item-level-2"><span>Quick Start<img style="transform:rotate(0deg)" class="menu-toggle" src="/img/arrow_down.png"/></span><ul><li class="menu-item menu-item-level-3"><a href="/en-us/docs/quick-start.html" target="_self">Nacos</a></li><li class="menu-item menu-item-level-3"><a href="/en-us/docs/quick-start-spring.html" target="_self">Nacos Spring</a></li><li class="menu-item menu-item-level-3"><a href="/en-us/docs/quick-start-spring-boot.html" target="_self">Nacos Spring Boot</a></li><li class="menu-item menu-item-level-3"><a href="/en-us/docs/quick-start-spring-cloud.html" target="_self">Nacos Spring Cloud</a></li><li class="menu-item menu-item-level-3"><a href="/en-us/docs/quick-start-docker.html" target="_self">Nacos Docker</a></li><li class="menu-item menu-item-level-3"><a href="/en-us/docs/use-nacos-with-dubbo.html" target="_self">Nacos with Dubbo</a></li><li class="menu-item menu-item-level-3"><a href="/en-us/docs/use-nacos-with-kubernetes.html" target="_self">Nacos with K8s</a></li><li class="menu-item menu-item-level-3"><a href="/en-us/docs/nacos-sync.html" target="_self">Nacos Sync</a></li></ul></li><li style="height:252px;overflow:hidden" class="menu-item menu-item-level-2"><span>User Guide<img style="transform:rotate(0deg)" class="menu-toggle" src="/img/arrow_down.png"/></span><ul><li class="menu-item menu-item-level-3"><a href="/en-us/docs/sdk.html" target="_self">Java SDK</a></li><li class="menu-item menu-item-level-3"><a href="/en-us/docs/other-language.html" target="_self">Other Language</a></li><li class="menu-item menu-item-level-3"><a href="/en-us/docs/open-api.html" target="_self">Open-API</a></li><li class="menu-item menu-item-level-3"><a href="/en-us/docs/nacos-spring.html" target="_self">Nacos Spring</a></li><li class="menu-item menu-item-level-3"><a href="/en-us/docs/system-configurations.html" target="_self">Nacos System Configurations</a></li><li class="menu-item menu-item-level-3"><a href="/en-us/docs/faq.html" target="_self">FAQ</a></li></ul></li><li style="height:36px;overflow:hidden" class="menu-item menu-item-level-2"><span>Admin Guide<img style="transform:rotate(-90deg)" class="menu-toggle" src="/img/arrow_down.png"/></span><ul><li class="menu-item menu-item-level-3"><a href="/en-us/docs/deployment.html" target="_self">Deployment Guide</a></li><li class="menu-item menu-item-level-3"><a href="/en-us/docs/cluster-mode-quick-start.html" target="_self">Cluster Mode Deployment</a></li><li class="menu-item menu-item-level-3"><a href="/en-us/docs/management-api.html" target="_self">Management OpenAPI</a></li><li class="menu-item menu-item-level-3"><a href="/en-us/docs/console-guide.html" target="_self">Admin Console Guide</a></li><li class="menu-item menu-item-level-3"><a href="/en-us/docs/monitor-guide.html" target="_self">Nacos Monitor Guide</a></li><li class="menu-item menu-item-level-3"><a href="/en-us/docs/nacos-config-benchmark.html" target="_self">Nacos Config Benchmark</a></li><li class="menu-item menu-item-level-3"><a href="/en-us/docs/nacos-naming-benchmark.html" target="_self">Nacos Naming Benchmark</a></li><li class="menu-item menu-item-level-3"><a href="/en-us/docs/nacos-sync-use.html" target="_self">Data Migration to Nacos</a></li></ul></li><li style="height:36px;overflow:hidden" class="menu-item menu-item-level-2"><span>Contributor Guide<img style="transform:rotate(-90deg)" class="menu-toggle" src="/img/arrow_down.png"/></span><ul><li class="menu-item menu-item-level-3"><a href="/en-us/docs/contributing.html" target="_self">Contribute to Nacos</a></li><li class="menu-item menu-item-level-3"><a href="/en-us/docs/contributing-flow.html" target="_self">Contributing Flow</a></li><li class="menu-item menu-item-level-3"><a href="/en-us/docs/pull-request.html" target="_self">Pull Request Template</a></li><li class="menu-item menu-item-level-3"><a href="/en-us/docs/how-to-reporting-bugs.html" target="_self">How to report bugs</a></li></ul></li><li style="height:36px;overflow:hidden" class="menu-item menu-item-level-2"><span>Community<img style="transform:rotate(-90deg)" class="menu-toggle" src="/img/arrow_down.png"/></span><ul><li class="menu-item menu-item-level-3"><a href="/en-us/docs/community.html" target="_self">Community</a></li><li class="menu-item menu-item-level-3"><a href="/en-us/docs/nacos-dev.html" target="_self">Develop Team</a></li></ul></li></ul></li></ul></div><div class="doc-content markdown-body"><h1>NacosSync migration user guide</h1>
<h2>Guide purposes</h2>
<ul>
<li>Start NacosSync service</li>
<li>By a simple example, demonstrates how to register to the Zookeeper Dubbo client migrated to Nacos.</li>
</ul>
<h2>Preparatory work</h2>
<p>Before you start the service, you need to install the following services:</p>
<ul>
<li>64bit OS: Linux/Unix/Mac/Windows supported, Linux/Unix/Mac recommended.</li>
<li>64bit JDK 1.8+: <a href="http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html">downloads</a>, <a href="https://docs.oracle.com/cd/E19182-01/820-7851/inst_cli_jdk_javahome_t/">JAVA_HOME settings</a>.</li>
<li>Maven 3.2.x+: <a href="https://maven.apache.org/download.cgi">downloads</a>, <a href="https://maven.apache.org/settings.html">settings</a>.</li>
<li>MySql 5.6.+</li>
</ul>
<h2>Get the installation package</h2>
<p>There are two ways to obtain NacosSync installation package:</p>
<ul>
<li>Direct download NacosSync binary installation package:<a href="https://github.com/nacos-group/nacos-sync/releases">nacosSync.${version}.zip</a></li>
<li>Download NacosSync source to build from the Github</li>
</ul>
<p>Package:</p>
<pre><code class="language-basic">cd nacosSync/
mvn clean package -U
</code></pre>
<p>The path of the target file:</p>
<pre><code class="language-basic">nacos-sync/nacossync-distribution/target/nacosSync.${version}.zip
</code></pre>
<p>Unpack the installation package, project file directory structure:</p>
<pre><code class="language-basic">nacosSync
├── LICENSE
├── NOTICE
├── bin
│   ├── nacosSync.sql
│   ├── shutdown.sh
│   └── startup.sh
├── conf
│   ├── application.properties
│   └── logback-spring.xml
├── logs
└── nacosSync-server.${version}.jar
</code></pre>
<h2>Initialize the database</h2>
<p>The system default configuration database is Mysql, can also support other relational database.
1.The database construction, the default database name for &quot;nacos_Sync&quot;.
2.The database table don't need to create separately, using the hibernate automatically by default build table function.
3.If you do not support automatic table, you can use the system's own build table SQL script, the script in the bin directory.</p>
<h2>Database configuration</h2>
<p>Database configuration file on <code>conf/application.properties</code>:</p>
<pre><code class="language-basic">spring.datasource.url=jdbc:mysql://127.0.0.1:3306/nacos_sync?characterEncoding=utf8
spring.datasource.username=root
spring.datasource.password=root
</code></pre>
<h2>Start server</h2>
<pre><code class="language-bash">$ nacosSync/bin:
sh startup.sh  restart
</code></pre>
<h2>Check system status</h2>
<p>1.Check system log</p>
<p>The path of the log in <code>nacosSync/logs/nacosSync.log</code>, check whether there are abnormal information.</p>
<p>2.Check system port</p>
<p>Port is the default system <code>8081</code>, you can define your own <code>application.properties</code>.</p>
<pre><code class="language-bash"><span class="hljs-variable">$netstat</span> -ano|grep 8081
tcp        0      0 0.0.0.0:8081                0.0.0.0:*                   LISTEN      off (0.00/0/0)
</code></pre>
<h2>Console</h2>
<p>Access path:</p>
<pre><code>http://127.0.0.1:8081/#/serviceSync
</code></pre>
<p><img src="https://img.alicdn.com/tfs/TB1EKbkJ3HqK1RjSZFEXXcGMXXa-2866-606.png" alt="image.png"></p>
<p>If there is no problem, check NacosSync has begun, normal NacosSync deployment structure:<img src="https://img.alicdn.com/tfs/TB107nfJ9zqK1RjSZFjXXblCFXa-1412-342.png" alt="image.png"></p>
<h2>Starting migration</h2>
<h3>Migration information</h3>
<p>Dubbo service deployment information:<img src="https://img.alicdn.com/tfs/TB1Ci_eJ4TpK1RjSZR0XXbEwXXa-938-700.png" alt="image.png"></p>
<p>The migration of services:</p>
<table>
<thead>
<tr>
<th>Service Name</th>
<th>Version</th>
<th>Group Name</th>
</tr>
</thead>
<tbody>
<tr>
<td>com.alibaba.nacos.api.DemoService</td>
<td>1.0.0</td>
<td>zk</td>
</tr>
</tbody>
</table>
<h3>Add the registry cluster information</h3>
<p>1.Click on the &quot;cluster configuration&quot; button in the left navigation bar, a new cluster, first add a Zookeeper cluster, select the cluster type for ZK.
<img src="https://img.alicdn.com/tfs/TB1oJDnJ7voK1RjSZFwXXciCFXa-2870-1130.png" alt="image.png"></p>
<blockquote>
<p>Note: the cluster name can customize, but once confirmed, cannot be modified, otherwise increase task based on the cluster, after NacosSync restart, success will not resume.</p>
</blockquote>
<p>2.The same steps, increase NacosSync cluster.
<img src="https://img.alicdn.com/tfs/TB1HQPhJVzqK1RjSZFCXXbbxVXa-2846-1042.png" alt="image.png"></p>
<p>3.After the completion of the add, can inquire on the list:
<img src="https://img.alicdn.com/tfs/TB1AX6fJVYqK1RjSZLeXXbXppXa-2864-824.png" alt="image.png"></p>
<h3>Add the synchronization task</h3>
<ol>
<li>Add a sync task, from Zookeeper cluster synchronization to Nacos cluster, synchronous granularity is service, it is called a Zookeeper cluster source cluster, Nacos cluster called target cluster.
<img src="https://img.alicdn.com/tfs/TB1tF_fJVYqK1RjSZLeXXbXppXa-2838-1138.png" alt="imagesd.png"></li>
</ol>
<p>Add finished, can be in service sync list, view has add synchronization task:
<img src="https://img.alicdn.com/tfs/TB1l6uJJ9zqK1RjSZPcXXbTepXa-2824-570.png" alt="image.png"></p>
<ol start="2">
<li>
<p>The synchronization is completed, check whether the data synchronization to success Nacos cluster, can query through the Nacos console.
<img src="https://img.alicdn.com/tfs/TB1tPneJ4TpK1RjSZR0XXbEwXXa-2872-828.png" alt="image.png"></p>
</li>
<li>
<p>At the moment, the data has been successfully from Zookeeper cluster synchronization to Nacos cluster, the deployment structure is as follows:
<img src="https://img.alicdn.com/tfs/TB14kriJ6TpK1RjSZKPXXa3UpXa-1724-772.png" alt="image.png"></p>
</li>
</ol>
<h3>Dubbo clients to connect to Nacos registry</h3>
<h4>Dubbo Consumer client migration</h4>
<p>Dubbo has supported Nacos registry, support version 2.5 +, need to add a Nacos registry of Dubbo extensions depends on:</p>
<pre><code class="language-basic">&lt;dependency&gt;
      &lt;groupId&gt;com.alibaba&lt;/groupId&gt;
      &lt;artifactId&gt;dubbo-registry-nacos&lt;/artifactId&gt;
			&lt;version&gt;0.0.2&lt;/version&gt;
&lt;/dependency&gt;
</code></pre>
<p>Increase Nacos client depends on:</p>
<pre><code class="language-basic">&lt;dependency&gt;
        &lt;groupId&gt;com.alibaba.nacos&lt;/groupId&gt;
        &lt;artifactId&gt;nacos-client&lt;/artifactId&gt;
        &lt;version&gt;0.6.2&lt;/version&gt;
&lt;/dependency&gt;
</code></pre>
<p>Configuration Dubbo Consumer Dubbo profile <code>Consumer. The yaml</code>, let the client can find Nacos cluster.</p>
<pre><code class="language-basic">spring:
  application:
name: dubbo-consumer
demo:
  service:
    version: 1.0.0
    group: zk
dubbo:
  registry:
    address: nacos://127.0.0.1:8848
</code></pre>
<p>Don't need to modify the code, configuration after the update, you can restart your application into law.</p>
<p>Consumer release is completed, the deployment of the structure is as follows:
<img src="https://img.alicdn.com/tfs/TB181fkJ3HqK1RjSZFEXXcGMXXa-1734-878.png" alt="image.png"></p>
<h4>Dubbo Provider migration</h4>
<p>Before you upgrade the Provider, you need to ensure that the Provider of services, are already configured in NacosSync, synchronous way from Nacos synchronization to Zookeeper, because the Provider connected to Nacos upgrade, you need to make sure that the old Dubbo Consumer client can subscribe to the Provider's address in the Zookeeper, now, we add a sync task:
<img src="https://img.alicdn.com/tfs/TB1pdDnJ7voK1RjSZFwXXciCFXa-2872-1060.png" alt="image.png"></p>
<p><img src="https://img.alicdn.com/tfs/TB19Ey_J6DpK1RjSZFrXXa78VXa-2842-660.png" alt="image.png"></p>
<blockquote>
<p>Note: Nacos synchronization to the Zookeeper service, do not need to fill in the version number, you in choosing the source cluster, the version number of the input box automatically hidden.</p>
</blockquote>
<p>Sync task is completed, you can upgrade the Provider, upgrade the Provider method, reference to upgrade the Consumer steps.</p>
<h3>New deployment structure</h3>
<ul>
<li>In the process of upgrading, there will be new and old versions of the client at the same time, the deployment structure is as follows:</li>
</ul>
<p><img src="https://img.alicdn.com/tfs/TB14Y_iJ3HqK1RjSZFPXXcwapXa-1728-838.png" alt="image.png"></p>
<ul>
<li>All client migration is completed, the deployment structure is as follows:</li>
</ul>
<p><img src="https://img.alicdn.com/tfs/TB1Cg2dJYvpK1RjSZPiXXbmwXXa-1466-864.png" alt="image.png"></p>
<p>Now, the Zookeeper cluster, NacosSync cluster can get offline.</p>
<h3>Attention</h3>
<ul>
<li>Synchronization task after adding, you need to ensure that the service is successful sync to the target cluster, can through the console the target cluster.</li>
<li>NacosSync support high availability cluster pattern deployment, you only need to put the database can be configured to the same.</li>
<li>Comb if not clear subscription and published service, suggested can do services are two-way synchronous.</li>
<li>Dubbo client currently does not support Nacos weighting function, if you are using the weight function, need to reconsider the plan.</li>
</ul>
</div></div></section><footer class="footer-container"><div class="footer-body"><img src="/img/nacos_gray.png"/><div class="cols-container"><div class="col col-12"><h3>Vision</h3><p>By providing an easy-to-use service infrastructure such as dynamic service discovery, service configuration, service sharing and management and etc., Nacos help users better construct, deliver and manage their own service platform, reuse and composite business service faster and deliver value of business innovation more quickly so as to win market for users in the era of cloud native and in all cloud environments, such as private, mixed, or public clouds.</p></div><div class="col col-6"><dl><dt>Documentation</dt><dd><a href="/en-us/docs/what-is-nacos.html" target="_self">Overview</a></dd><dd><a href="/en-us/docs/quick-start.html" target="_self">Quick start</a></dd><dd><a href="/en-us/docs/contributing.html" target="_self">Developer guide</a></dd></dl></div><div class="col col-6"><dl><dt>Resources</dt><dd><a href="/en-us/community/index.html" target="_self">Community</a></dd><dd><a href="https://www.aliyun.com/product/acm?source_type=nacos_pc_20181219" target="_self">Cloud Service ACM</a></dd><dd><a href="https://www.aliyun.com/product/edas?source_type=nacos_pc_20181219" target="_self">Cloud Service EDAS</a></dd><dd><a href="https://www.aliyun.com/product/ahas?source_type=nacos_pc_20190225" target="_self">Cloud Service AHAS</a></dd></dl></div></div><div class="copyright"><span>@ 2018 The Nacos Authors | An Alibaba Middleware (Aliware) Project</span></div></div></footer></div></div>
	<script src="https://f.alicdn.com/react/15.4.1/react-with-addons.min.js"></script>
	<script src="https://f.alicdn.com/react/15.4.1/react-dom.min.js"></script>
	<script>
		window.rootPath = '';
  </script>
	<script src="/build/documentation.js"></script>
</body>
</html>